package legumes.client.ui;

import legumes.client.services.callbacks.GetSellSessionForCustomerCallback;
import legumes.client.services.util.rpc.RPCCallSequencer;
import legumes.client.ui.top.TopPanel;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.WidgetCanvas;
import com.smartgwt.client.widgets.layout.VLayout;

public class MainPanel extends VLayout {

	private TopPanel topPanel;
	private MainCenterPanel centerPanel;
	
	public MainPanel() {
		super();
		setWidth100();
		setHeight100();
		setAlign(Alignment.CENTER);
		
		topPanel = new TopPanel();
		centerPanel = new MainCenterPanel();
		
		WidgetCanvas wcTopPanel = new WidgetCanvas(topPanel);
		wcTopPanel.setAutoHeight();
		setMembers(wcTopPanel, centerPanel);
		
		bind();
	}
	
	private void bind(){
	}
	
	public void initData(){
		final GetSellSessionForCustomerCallback c = new GetSellSessionForCustomerCallback();
		  RPCCallSequencer callSequencer = new RPCCallSequencer(
			"Chargement en cours...");
		  callSequencer.addCall(c);
			callSequencer.addRunnable(new Runnable() {
				public void run() {
					centerPanel.initData(c.getSellSessionForCustomer());
				}
			});
			callSequencer.callSequence();	
	}
}
